package com.chain.qs.modules.biz.dp.handler;

import com.chain.qs.modules.biz.entity.EquipmentItemRecordCAHCTransDev;
import com.chain.qs.modules.biz.service.EquipmentItemRecordCAHCTransDevService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.util.Map;

/**
 * CAHCTransDev
 */
@Component("CAHCTransDev")
public class CAHCTransDev extends AbstractDPHandler {
    @Resource
    private EquipmentItemRecordCAHCTransDevService equipmentItemRecordCAHCTransDevService;

    public void saveData(Map<String, Object> params) {
        EquipmentItemRecordCAHCTransDev entity = new EquipmentItemRecordCAHCTransDev();
        entity.setOfficeCode(officeCode);
        entity.setSgroupId(sgroupId);
        entity.setGitemId(deviceId);
        entity.setForwardPower(params.get("forward_power") != null ? params.get("forward_power").toString() : "");
        entity.setBackwardPower(params.get("backward_power") != null ? params.get("backward_power").toString() : "");
        entity.setTemp(params.get("temp") != null ? params.get("temp").toString() : "");
        entity.setVolA(params.get("vol_a") != null ? params.get("vol_a").toString() : "");
        entity.setVolB(params.get("vol_b") != null ? params.get("vol_b").toString() : "");
        entity.setVolC(params.get("vol_c") != null ? params.get("vol_c").toString() : "");
        entity.setCurt(params.get("curt") != null ? params.get("curt").toString() : "");

        entity.setTimeStamp(new Timestamp(System.currentTimeMillis()));
        equipmentItemRecordCAHCTransDevService.save(entity);
    }
}
